/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.core.commands.connection;

import org.eclipse.draw2d.geometry.Point;
import org.eclipse.gef.commands.Command;

import com.cea.papyrus.diagraminterchange2.di2.GraphEdge;

/**
 * 
 */
public class DeleteBendpointCommand extends Command {
  
  /**
   * 
   */
  private GraphEdge connection;
  
  /**
   * 
   */
  private Point oldLocation; 
  
  /**
   * 
   */
  private int index;

  
  /**
   * 
   */
  @Override
public void execute() {
    
    oldLocation = (Point) connection.getWaypoints().remove(index);//delete BendPoints from GraphEdge
  }

  /**
   * 
   * 
   * @param model 
   */
  public void setConnectionModel(Object model) {
    connection = (GraphEdge) model;
  }

  /**
   * 
   * 
   * @param i 
   */
  public void setIndex(int i) {
    index = i;
  }

  
  /**
   * 
   */
  @Override
public void undo() {
    connection.getWaypoints().add(index, oldLocation);
  }
}
